package com.zcs.app.wisdomschool.ui.fragment;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.greateffect.littlebud.lib.adapter.CommonRecyclerAdapter;
import com.greateffect.littlebud.lib.base.BaseNormalFragmentAdvSimple;
import com.greateffect.littlebud.lib.provider.PicProvider;
import com.greateffect.littlebud.lib.utils.GlideStaticUtils;
import com.greateffect.littlebud.lib.utils.JListKit;
import com.zcs.app.wisdomschool.R;
import com.zcs.app.wisdomschool.bean.MyProcessBean;

import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.ViewById;

import java.util.List;

/**
 * Created by ZengCS on 2019/9/24.
 * E-mail:zengcs@vip.qq.com
 * Add:成都市天府软件园E3
 * Desc:类说明
 */
@EFragment(R.layout.fragment_me)
public class MeFragment extends BaseNormalFragmentAdvSimple {
    @ViewById(R.id.id_rv_me)
    RecyclerView mRecyclerView;
    @ViewById(R.id.id_container_toolbar)
    ViewGroup mToolbarContainer;

    private List<MyProcessBean> mItems = JListKit.newArrayList();

    @Override
    protected void initData() {
        super.setToolbarPaddingWhenTransStatusBar(mToolbarContainer);
        initAdapter();
    }

    private void initAdapter() {
        mItems.add(new MyProcessBean("6月28报寝记录", "根据学院排名或休假…", "2018-11-30", R.mipmap.pic_r_1));
        mItems.add(new MyProcessBean("6月28修改记录", "根据学院排名或休假…", "2018-11-30", R.mipmap.pic_r_2));
        mItems.add(new MyProcessBean("6月28休假记录", "根据学院排名或休假…", "2018-11-30", R.mipmap.pic_r_3));
        mItems.add(new MyProcessBean("6月27报寝记录", "根据学院排名或休假…", "2018-11-30", R.mipmap.pic_r_1));
        mItems.add(new MyProcessBean("6月27修改记录", "根据学院排名或休假…", "2018-11-30", R.mipmap.pic_r_2));
        mItems.add(new MyProcessBean("6月27休假记录", "根据学院排名或休假…", "2018-11-30", R.mipmap.pic_r_3));
        mItems.add(new MyProcessBean("6月26报寝记录", "根据学院排名或休假…", "2018-11-30", R.mipmap.pic_r_1));
        mItems.add(new MyProcessBean("6月26修改记录", "根据学院排名或休假…", "2018-11-30", R.mipmap.pic_r_2));
        mItems.add(new MyProcessBean("6月26休假记录", "根据学院排名或休假…", "2018-11-30", R.mipmap.pic_r_3));

        CommonRecyclerAdapter<MyProcessBean> mAdapter = new CommonRecyclerAdapter<MyProcessBean>(R.layout.item_my_process, mItems) {
            @Override
            protected void convert(BaseViewHolder helper, MyProcessBean item) {
                helper.setText(R.id.id_tv_process_title, item.getTitle());
                helper.setText(R.id.id_tv_process_desc, item.getDesc());
                helper.setText(R.id.id_tv_process_date, item.getDate());
                //GlideStaticUtils.displayImage(item.getPic(), R.drawable.empty_photo, helper.getView(R.id.id_iv_process_pic));
                helper.setImageResource(R.id.id_iv_process_pic, item.getPic());
            }
        };
        View footView = LayoutInflater.from(getAttachedContext()).inflate(R.layout.simple_foot_view, null, false);
        mAdapter.addFooterView(footView);
        mAdapter.setOnItemClickListener((adapter, view, position) -> {
            try {
                MyProcessBean myProcessBean = mItems.get(position);
                showToast(myProcessBean.getTitle());
            } catch (Exception e) {
                e.printStackTrace();
            }
        });

        mRecyclerView.setAdapter(mAdapter);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getAttachedContext()));
    }
}
